<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,Chrome=1">
<meta http-equiv="X-UA-Compatible" content="IE=9" />
<meta name="renderer" content="webkit">
<title>人员信息管理</title>
<link rel="stylesheet" type="text/css" href="../../css/cm-default.css"  />
<link rel="stylesheet" type="text/css" href="../../lib/ligerUI/skins/Aqua/css/ligerui-all.css" />
<link rel="stylesheet" type="text/css" href="../../lib/ligerUI/skins/Gray2014/css/all.css" />
<link rel="stylesheet" type="text/css" href="../../lib/ligerUI/skins/ligerui-icons.css" />
<link rel="stylesheet" type="text/css" href="../../lib/bootstrap//css/bootstrap.css"/>
<link type="text/css" rel="stylesheet" href="../../css/public.css"  />
<link type="text/css" rel="stylesheet" href="../../css/pub.css"  />
<script src="../../lib/jquery/jquery-1.9.1.min.js" type="text/javascript"></script>
<script src="../../lib/ligerUI/js/ligerui.all.js" type="text/javascript"></script>
<script src="../../lib/autoInput/AutoInput.js" type="text/javascript"></script>
<script src="../../js/common.js" type="text/javascript"></script>
<script src="../../lib/bootstrap/js/bootstrap.js" type="text/javascript"></script>
<script src="../../js/pub.js" type="text/javascript"></script>

<script type="text/javascript">
    var GridNameCode = [
        {"Key_Nvarchar":"PartnerSSN","Value_Nvarchar":"身份证号"},
        {"Key_Nvarchar":"PartnerUID","Value_Nvarchar":"员工编号"},
        {"Key_Nvarchar":"PartnerNAME","Value_Nvarchar":"员工姓名"}
    ] ;
    $(function() {
        InitAutoInput("gridName", GridNameCode, { key: "Key_Nvarchar", val: "Value_Nvarchar", format: "Value_Nvarchar" }, 'json');
    });
</script>
<script type="text/javascript">
    var defGrid,paramS;
    paramS =new Object();
    $(function(){
        defGrid = $("#query_list").ligerGrid({
            columns:[
                {display:'员工编号',name:'userid',width:80,minWidth:60},
                {display:'员工姓名',name:'name',width:80,minWidth:60},
                {display:'所属公司',name:'company_id',width:100,minWidth:60,render:company_org},
                {display:'所属部门',name:'dept_id',width:100,minWidth:60,render:dept_org},
                {display:'身份证',name:'ssn',width:120,minWidth:60},
                {display:'性别',name:'sex',width:50,minWidth:60},
                {display:'生日',name:'birthday',width:80,minWidth:60},
                {display:'民族',name:'nation',width:60,minWidth:60},
                {display:'地址',name:'address',width:180,minWidth:60},
                {display:'手机号',name:'mobile_phone',width:80,minWidth:60},
                {display:'固定电话',name:'fix_phone',width:90,minWidth:60},
                {display:'是否可用',name:'user_valid',width:90,minWidth:60,render:yesOrNo},
            ],
            pageSize:10,
            usePager: true,
            dataAction:'server',
            sqlid:"employee.select.employeeinfo.query",
            url: '/employee/query',
            contentType: "application/json; charset=utf-8",
            postData:paramS,
            width:'96%',
            height:'96%',
            checkbox:false,
            rownumbers:false,
            fixedCellHeight:false,
            colDraggable:true,
            enabledEdit:false,
            clickToEdit:false,
            isScroll:true,
            onDblClickRow:openMx,  //双击查询
            onSelectRow:function(rowdata, rowindex){$("#txtrowindex").val(rowindex);},
            param_org:'org_list',
            param_yesOrNo:'yesOrNo',
        });
        $("#pageloading").hide();

    });

    function company_org(item) {
    	var orgTpye = new Object();
    	orgTpye.org_type ="0";
        return paramRender(item, defGrid.options.param_org, item.company_id,orgTpye,false);
    }

    function dept_org(item) {
    	var orgTpye = new Object();
    	orgTpye.org_type ="1";
        return paramRender(item, defGrid.options.param_org, item.dept_id,orgTpye,false);
    }
    
    function yesOrNo(item) {
        return paramRender(item, defGrid.options.param_yesOrNo, item.user_valid);
    }


    //查询方法
    function toQuery_Common() {
        var key = $("#gridNameCode").val();
        var val = $("#gridName").val();
        key = key.split("Q")[0];
        //设置查询条件参数
        switch (key)
        {
            case "PartnerSSN":
                paramS.ssn = val;
                break;
            case "PartnerUID":
                paramS.userid = val;
                break;
            case "PartnerNAME":
                paramS.name = val;
                break;
            default:
                paramS.userid = "";
                paramS.ssn = "";
                paramS.name = "";
        }

        paramS.data=JSON.stringify(paramS);
        // l-list 线性结构，默认；t-tree 树型结构
        paramS.rt='l';
        //重置页码
        defGrid.set({
            page : 1,
            newPage : 1,
            postData : paramS
        });
        // grid 重新加载数据
        defGrid.loadData();
    }
    function toQuery() {
    	paramS.ssn = $("#ssnQ").val();
    	paramS.userid = $("#useridQ").val();
    	paramS.name = $("#nameQ").val();
        paramS.data=JSON.stringify(paramS);
        // l-list 线性结构，默认；t-tree 树型结构
        paramS.rt='l';
        //重置页码
        defGrid.set({
            page : 1,
            newPage : 1,
            postData : paramS
        });
        // grid 重新加载数据
        defGrid.loadData();
    }
    //新增方法
    function new_partner_add() {
        alter("暂时不支持！");
    }
    //编辑
    function openModify() {
    	  var row = defGrid.getSelectedRow();
          if (!row) {
              $.ligerDialog.error('请先选择要修改的员工记录。','错误');
              return;
          }
          var UID=row.userid;
          parent.f_addTab('update_UserS'+UID,'单据明细信息('+UID+')','./html/employee/employee_edit.html?userid='.concat(UID));
    }
    //明细页面
    function openMx(){
        var row = defGrid.getSelectedRow();
        if (!row) {
            $.ligerDialog.error('请先选择要查看的员工记录。','错误');
            return;
        }
        var UID=row.userid;
        parent.f_addTab('search_UserS'+UID,'单据明细信息('+UID+')','./html/employee/employee_detail.html?userid='.concat(UID));
    }
    /*
     删除处理
     */
    function deleteRow() {
        var row = defGrid.getSelectedRow();
        if (!row) {
            $.ligerDialog.error('请先选择要删除的员工信息记录。','错误');
            return;
        }
        var userid = row.userid;
        $.ligerDialog.confirm('您确定要删除该项数据吗？', function(r) {
            if (!r)
              return;
           toDel(userid);
        })
    }
    // 删除处理业务处理
    function toDel(id) {
        ajaxSubmitGet("/employee/deleteEmployee/" + id,function(data) {
            if (data) {
                if (parseInt(data['status']) > 0) {
                    toQuery();
                    $.ligerDialog.success('删除成功');
                } else {
                    $.ligerDialog.error('删除失败');
                }
            }
        });
    }
    
    function employee_ty(){
    	   var row = defGrid.getSelectedRow();
           if (!row) {
               $.ligerDialog.error('请先选择要停用的员工信息记录。','错误');
               return;
           }
          if(row.user_valid =='0'){
        	    $.ligerDialog.error('请先选择已启用员工信息记录。','错误');
                return; 
          }
          var data = new Object();
          data.userid = row.userid;
          data.user_valid = '0';
          ajaxSubmit("/employee/updateEmployeeValid", data, function(data) {
      		if (parseInt(data['status']) > 0) {
      				$.ligerDialog.success('员工基本信息停用成功！');
      				toQuery();
      		} else {
      			$.ligerDialog.error('员工基本信息停用失败！');
      		}
      	});
    }
    function employee_qy(){
 	   var row = defGrid.getSelectedRow();
        if (!row) {
            $.ligerDialog.error('请先选择要启用的员工信息记录。','错误');
            return;
        }
       if(row.user_valid =='1'){
     	    $.ligerDialog.error('请先选择已停用员工信息记录。','错误');
             return; 
       }
       var data = new Object();
       data.userid = row.userid;
       data.user_valid = '1';
       ajaxSubmit("/employee/updateEmployeeValid", data, function(data) {
   		if (parseInt(data['status']) > 0) {
   				$.ligerDialog.success('员工基本信息启用成功！');
   				toQuery();
   		} else {
   			$.ligerDialog.error('员工基本信息启用失败！');
   		}
   	});
 }
    
</script>
<style type="text/css">
    label{margin: 5px 20px 5px 15px;}
    .fields{height:35px;padding-top:5px;}
    .dict-info{width: 260px;padding: 10px;}
    .diff {margin:3px 0;}
    .lineD {width:99%;float:left;position:relative;overflow:hidden;margin:10px 0 2px 2px}
    .labelD {width:13%;position:relative;float:left;padding-top:3px;}
    .dplD {width:36%;position:relative;float:left;}
    .title{font-size:14px;font-weight:bold;background-position:left;padding-left:18px;}
    .l-dialog-content-nopadding{padding:0 !important;}
</style>
</head>
<body>
<div class="list_tab contextHeight">
    <div class="searchContent">
        <div class="commenSearch">
            <div class="commenGotoSite">
                <button type="button" onclick="openModify();" class="btn btn-primary btn-xs">
                    &nbsp;&nbsp;<span class="glyphicon glyphicon-pencil"></span>&nbsp;&nbsp;
                </button>
                <button type="button" onclick="openMx();" class="btn btn-primary btn-xs">
                    &nbsp;&nbsp;<span class="glyphicon glyphicon-eye-open"></span>&nbsp;&nbsp;
                </button>
                <button type="button" onclick="deleteRow()" class="btn btn-primary btn-xs">
                    &nbsp;&nbsp;<span class="glyphicon glyphicon-trash"></span>&nbsp;&nbsp;
                </button>
                 <button type="button" onclick="employee_qy();" class="btn btn-primary btn-xs">
                    &nbsp;&nbsp;<span>启用</span>&nbsp;&nbsp;
                </button>
                  <button type="button" onclick="employee_ty();" class="btn btn-primary btn-xs">
                    &nbsp;&nbsp;<span>停用</span>&nbsp;&nbsp;
                </button>
            </div>
            <div class="commenSearchSite">
                <div class="form-inline" action="">
                    <div class="form-group contextWidth">
                        <div class="autoBox">
                            <span class="glyphicon glyphicon-search"></span>
                            <span class="commenSearchTitle"></span>
                            <input type="text" class="autoInput form-control input-sm" id="gridName" style="width:75%;" value="" autocomplete="off" />
                            <div class="autoList">
                            </div>
                            <input id="gridNameCode" name="gridNameCode" type="hidden" value="" />
                            <div style="display:inline-block;position:relative;">
                             	<span class="zkbutton" onclick="selectToggle(this);">
			                        	<span id="searchMark" class="glyphicon glyphicon-menu-down"></span>
			                        </span>
                            </div>
                            &nbsp;&nbsp;
                            <button type="button" onclick="toQuery_Common();" class="btn btn-primary btn-sm">查询</button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div class="searchForm" style="display:none;">
            <form id="form1" class="form-inline" action="">
               <div class="form-group">
                    <label for="useridQ">员工编号:</label>
                    <input type="text" class="form-control input-sm" id="useridQ" placeholder="">
                </div>
                <div class="form-group">
                    <label for="ssnQ">身份证号:</label>
                    <input type="text" class="form-control input-sm" id="ssnQ" placeholder="">
                </div>
                <div class="form-group">
                    <label for="nameQ">员工姓名:</label>
                    <input type="text" class="form-control input-sm" id="nameQ" placeholder="">
                </div>
                &nbsp;&nbsp;
                <button type="button" onclick="toQuery();" class="btn btn-primary btn-sm">查询</button>
                &nbsp;&nbsp;
                <button type="button" onclick="toReset('#useridQ,#ssnQ,#nameQ');" class="btn btn-primary btn-sm">清空</button>
            </form>
        </div>
    </div>
    <div class="listTable">
        <div class="split_line"></div>
        <div id="query_list" style="padding: 0;margin:0 auto;"></div>
    </div>
</div>
<div id="pageloading"></div>
</body>
</html>